package mortal.game
{
	import com.gengine.debug.*;
	import com.gengine.global.*;
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;
	import mortal.game.manager.*;
	import mortal.game.mvc.*;
	import mortal.game.scene.map.*;
	//import mortal.game.scene.player.entity.*;
	import mortal.game.view.common.*;
	import mortal.game.view.mainUI.*;
	
	public class GameLayout extends Object
	{
		private var _stage:Stage;
		private var _resizeCount:int = 0;
		private var _isReSize:Boolean = false;
		private static var _instance:GameLayout;
		
		public function GameLayout()
		{
			this._stage = Global.stage;
			if (_instance != null)
			{
				throw new Error(" GameLayout 是单例 ");
			}
			
		}
		
		public function init() : void
		{
			this._stage.addEventListener(Event.RESIZE, this.onResizeHandler);
			
		}
		
		private function onResizeHandler(event:Event) : void
		{
			if (event.target is Stage)
			{
				if (this._isReSize == false)
				{
					this._isReSize = true;
					setTimeout(this.resize, 50);
				}
				_resizeCount = this._resizeCount + 1;
	
			}
			
		}
		
		public function resize(param1:Boolean = true) : void
		{
			/*
			Log.debug("场景resize:" + this._resizeCount);
			this._resizeCount = 0;
			this._isReSize = false;
			var _loc_2:* = this._stage.stageWidth / SceneRange.display.width;
			var _loc_3:* = this._stage.stageHeight / SceneRange.display.height;
			var _loc_4:* = this._stage.stageWidth;
			var _loc_5:* = this._stage.stageHeight;
			SceneRange.display.width = _loc_4;
			SceneRange.display.height = _loc_5;
			if (Game.mapInfo)
			{
				SceneRange.init(Game.mapInfo);
			}
			if (RolePlayer.instance.isInitInfo)
			{
				RolePlayer.instance.setPixlePoint(RolePlayer.instance.x, RolePlayer.instance.y);
			}
			if (GameController.gameui.view)
			{
				GameUI(GameController.gameui.view).resize(_loc_4, _loc_5);
			}
			if (SkillProgress.instance.parent != null)
			{
				SkillProgress.instance.resize(_loc_4, _loc_5 * 3 / 2 - 20);
			}
			MsgManager.resize();
			EffectManager.stageResize();
			GameController.relive.stageResize();
			GameController.guideWelcome.stageResize();
			GameController.taskTrack.stageResize();
			GameController.status.stageResize();
			GameController.effect.stageResize();
			GameController.copy.stageResize();
			GameController.guidOpt.stageResize();
			GameController.quickRegister.stageResize();
			GameController.msgTip.stageResize();
			LayerManager.windowLayer.resize(_loc_2, _loc_3);
			*/
		}
		
		public static function get instance() : GameLayout
		{
			if (_instance == null)
			{
				_instance = new GameLayout;
			}
			return _instance;
		}
		
	}
}
